package com.cxf.windex.rest;

import com.cxf.windex.base.msg.ObjectRestResponse;
import com.cxf.windex.base.msg.TableResultResponse;
import com.cxf.windex.base.rest.BaseRestController;
import com.cxf.windex.base.util.IdUtil;
import com.cxf.windex.biz.HumanResourcesBiz;
import com.cxf.windex.entity.BResouces;
import com.cxf.windex.entity.HumanResources;
import com.cxf.windex.entity.JsNotes;
import com.cxf.windex.entity.MoneyLog;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 人力资源招聘
 *
 * @author chenxf
 * @version 1.0
 * @date 2018-12-17 11:06
 **/
@Api(tags = {"通用 - 人力资源招聘接口"})
@RestController
@RequestMapping("/user/humanResources")
public class HumanResourcesController extends BaseRestController<HumanResourcesBiz, HumanResources> {
    @ApiOperation(value = "查询资金记录", notes = "查询资金记录列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "limit", value = "记录数 默认10",   paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "offset", value = "页码 默认 1",   paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "status", value = "状态 1有效 2失效 默认1",   paramType = "query", dataType = "String")
    })
    @GetMapping("/list")
    public TableResultResponse<HumanResources> list(
            @RequestParam(defaultValue = "10") int limit, @RequestParam(defaultValue = "1") int offset,
            @RequestParam(defaultValue = "1") String status) {
        List<HumanResources> items = baseBiz.list(limit, offset, status);
        PageInfo<HumanResources> pageInfo = new PageInfo<>(items);
        return new TableResultResponse<>(Integer.parseInt(String.valueOf(pageInfo.getTotal())),
                offset, limit,
                items);
    }

    @ApiOperation(value = "获取招聘信息", notes = "获取招聘信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "招聘信息ID", required = true, paramType = "path", dataType = "Long")
    })
   @GetMapping("/getInfo/{id}")
    public ObjectRestResponse getInfo(@PathVariable Long id){
        HumanResources entity=baseBiz.selectById(id);
        if(entity==null){
            return new ObjectRestResponse("找不到相关信息").rel(false);
        }
        return new ObjectRestResponse("查询成功").rel(true).result(entity);
    }

    @ApiOperation(value = "保存", notes = "保存")
    @PostMapping("/save")
    public ObjectRestResponse save(HumanResources entity) {
        baseBiz.save(entity);
        return new ObjectRestResponse().rel(true).msg("保存成功");
    }
}
